package com.market.exception;

import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import com.market.bean.common.BaseRespVo;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author fan
 * @Description:
 * @since 2022/12/29 17:34
 */
@RestControllerAdvice
public class ExceptionControllerAdvice {

    @ExceptionHandler(ValidationException.class)
    public BaseRespVo validationExceptionResolver(ValidationException exception) {
        String message = exception.getMessage();
        return BaseRespVo.invalidParameter(message);
    }

    @ExceptionHandler(InvalidFormatException.class)
    public BaseRespVo invalidFormatExceptionResolver(InvalidFormatException exception) {
        return BaseRespVo.invalidParameter("参数不合格");
    }

}
